package com.turnengine.client.local.location.bean;

import com.javabi.common.io.data.IDataReader;
import com.javabi.common.io.data.IDataWriter;
import java.io.IOException;

/**
 * The Coordinate Grid Serializer.
 */
public class CoordinateGridSerializer implements ICoordinateGridSerializer {

	@Override
	public ICoordinateGrid readObject(IDataReader reader) throws IOException {

		// Read fields
		int length = reader.readInt();
		int width = reader.readInt();

		// Create object
		ICoordinateGrid object = new CoordinateGrid();
		object.setLength(length);
		object.setWidth(width);
		return object;
	}

	public void writeObject(IDataWriter writer, ICoordinateGrid object) throws IOException {

		// Get fields
		int length = object.getLength();
		int width = object.getWidth();

		// Write fields
		writer.writeInt(length);
		writer.writeInt(width);
	}
}
